<template>
    <div id="dialogStaffMessage">
        <el-dialog
            v-if="dialogFormVisible"
            :visible.sync="dialogFormVisible"
            :title="dialogTitle"
            width="620px"
            :close-on-click-modal="false"
        >
            <el-form
                ref="subForm"
                :inline="true"
                :model="submitFormData"
                class="search-form-inline"
                size="small"
                :label-position="labelPosition"
            >
                <el-row>
                    <el-form-item label="姓名" prop="roleName">
                    <el-input v-model="submitFormData.roleName" />
                </el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="登录名" prop="loginName">
                    <el-input v-model="submitFormData.loginName" />
                </el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="密码" prop="password">
                    <el-input v-model="submitFormData.password" />
                </el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="联系方式" prop="telphone">
                    <el-input v-model="submitFormData.telphone" />
                </el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="角色" prop="role">
                    <el-select v-model="submitFormData.role">
                        <el-option
                            v-for="item in roleList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        ></el-option>
                    </el-select>
                </el-form-item>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="submitForm">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import apisStaffMessage from "@/api/systemSetting/staffMessage"; //员工管理列表接口

export default {
    name: "dialogStaffMessage",
    components: {apisStaffMessage},
    data() {
        return {
            dialogFormVisible: false,
            dialogTitle: "",
            labelPosition: "right",
            submitFormData: {
                roleName: "",
                loginName:"",
                password:"",
                telphone: "",
                role:""
            },
            roleList:[{
                value:'0',
                label:'管理员'
            },{
                value:'1',
                label:'财务管理'
            }]
        };
    },
    methods: {
        open(data) {
            let _this = this;
            if (data && data.id) {
                _this.dialogTitle = "修改用户";
                apisStaffMessage.getDetail(data.id).then(res=>{
                    this.submitFormData = res.data.roleMessageList;
                })
            } else {
                _this.dialogTitle = "新增用户";
                _this.submitFormData = {};
            }
            _this.dialogFormVisible = true;
        },
        submitForm() {
            apisStaffMessage.submitForm(this.submitFormData).then(d => {
                this.dialogFormVisible = false;
                this.$parent.getList();  
            })
        }
    }
};
</script>
<style lang="" scoped>
</style>